import actionType from '../actions/actiontype'
const initState = {
    isLoading: false,
    List: [{
            id: 1,
            title: '通知中心消息1',
            desc: '这是一个消息,还没有被阅读',
            hsaRead: false
        },
        {
            id: 2,
            title: '通知中心消息3',
            desc: '这是一个消息,已经被阅读',
            hsaRead: true
        },
        {
            id: 3,
            title: '通知中心消息3',
            desc: '这是一个消息,还没有被阅读',
            hsaRead: false
        },
        {
            id: 4,
            title: '通知中心消息4',
            desc: '这是一个消息,已经被阅读',
            hsaRead: true
        },
        {
            id: 5,
            title: '通知中心消息5',
            desc: '这是一个消息,还没有被阅读',
            hsaRead: false
        }

    ]
}

export default (state = initState, action) => {
    switch (action.type) {
        case actionType.GETADMINNOTE:
         
            
                state=action.payload.datas
                return {
                    ...state,
                   
                }
    

        case actionType.READNOTE:
            const newlist = state.List.map((item) => {
                if (item.id === action.payload.id) {
                    item.hsaRead = true
                    item.desc = '这是一个消息,已经被阅读'
                }
                return item
            })
            state.List=newlist
            return {
                ...state,
               
            }
        case actionType.ALLREADNOTE:
                const newlistall = state.List.map((item) => {
                    item.hsaRead = true
                    item.desc = '这是一个消息,已经被阅读'
                    return item
                })
                state.List = newlistall
               console.log(state);
                return {
                    ...state,
                   
                }
        case actionType.READNOTESTART:
                   console.log('start');
                   
                state.isLoading=true;
                return {
                    ...state,
                   
                }
                
        case actionType.READNOTEFINISH:
            console.log('fainish');
            
                state.isLoading=false;
                return {
                    ...state,
                   
                } 
                     
         default:
                return  state
    }
}